package com.cn.boot.spring.service.impl;

import com.cn.boot.spring.entity.RoleEntity;
import com.cn.boot.spring.mapper.RoleMapper;
import com.cn.boot.spring.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements IRoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Override
    public List<RoleEntity> findAll() {
        return roleMapper.findAll();
    }

    @Override
    public RoleEntity findById(Integer id) {
        return roleMapper.findById(id);
    }

    @Override
    public Integer addRole(RoleEntity roleEntity) {
        roleEntity.setId(null);
        return roleMapper.add(roleEntity);
    }

    @Override
    public void addRoles(List<RoleEntity> roles) {
        roles.stream().forEach(roleMapper::add);
    }

    @Override
    public void del(List<Integer> ids) {
        ids.stream().forEach(roleMapper::del);
    }

    @Override
    public Integer update(RoleEntity roleEntity) {
        return roleMapper.update(roleEntity);
    }
}
